package com.lagou.springsession.sessionController;

import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpSession;

/**
 * @Author: Eric.zhou
 * @Date: 2020/4/13 16:53
 */
@Controller
@EnableRedisHttpSession
public class SessionControler {


    @RequestMapping("/index")
    public String index() {
        System.out.println("123");
        return "index";
    }

    @RequestMapping("/success")
    public String success() {
        System.out.println("123");
        return "success";
    }


    /**
     * url: http://localhost:8080/demo/handle01
     */
    @RequestMapping("/login")
    public ModelAndView handle01(HttpSession session) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("success");
        System.out.println("123");
        session.setAttribute("USER_SESSION", "admin");
        return modelAndView;

    }
}
